-
Notifications
You must be signed in to change notification settings - Fork 46
feat(wp): hot and cold self managed #644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(wp): hot and cold self managed #644
Conversation
OttoAllmendinger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flush: not btc
500a538 to
2b6bd0f
Compare
| seed: Yup.string(), | ||
| }).required(); | ||
|
|
||
| const validationSchema = getValidationSchema('cold'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a dangling const ?
|
|
||
| const formik = useFormik<EcdsaFormValues>({ | ||
| onSubmit, | ||
| initialValues: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add walletType as the form state, and default to cold. That way you won't need an extra state, and you won't need to add a hook, it could be a straight forward function (useWalletTypeLabels)
| seed: Yup.string(), | ||
| }).required(); | ||
|
|
||
| const validationSchema = getValidationSchema('cold'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here?
91e723f to
313a656
Compare
mohammadalfaiyazbitgo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's update the Yup schema, unsure if we need the validation changes added.
| const getValidationSchema = (walletType: WalletType) => Yup.object({ | ||
| walletType: Yup.string().oneOf(['cold', 'hot']).required(), | ||
| userKey: Yup.string().required(), | ||
| backupKey: Yup.string().required(), | ||
| bitgoKey: Yup.string().required(), | ||
| walletPassphrase: Yup.string(), | ||
| walletPassphrase: walletType === 'hot' ? Yup.string().required() : Yup.string(), | ||
| startingScanIndex: Yup.number(), | ||
| endingScanIndex: Yup.number().moreThan( | ||
| Yup.ref('startingScanIndex'), | ||
| 'Ending scan index must be greater than starting scan index' | ||
| ), | ||
| seed: Yup.string(), | ||
| }).required(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that walletType is a form value, I don't think you need to make this dynamic: https://stackoverflow.com/questions/49394391/conditional-validation-in-yup
| validate: (values) => { | ||
| try { | ||
| getValidationSchema(values.walletType as WalletType).validateSync(values, { abortEarly: false }); | ||
| return {}; | ||
| } catch (error: any) { | ||
| const errors: Record<string, string> = {}; | ||
| error.inner?.forEach((err: any) => { | ||
| if (err.path) { | ||
| errors[err.path] = err.message; | ||
| } | ||
| }); | ||
| return errors; | ||
| } | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need this?
| validate: (values) => { | ||
| try { | ||
| getValidationSchema(values.walletType as WalletType).validateSync(values, { abortEarly: false }); | ||
| return {}; | ||
| } catch (error: any) { | ||
| const errors: Record<string, string> = {}; | ||
| error.inner?.forEach((err: any) => { | ||
| if (err.path) { | ||
| errors[err.path] = err.message; | ||
| } | ||
| }); | ||
| return errors; | ||
| } | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
Ticket: WP-1338